package com.it.base.thread.pool.MyCustomThreadPool.CustomRejectedExecution;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 自定义异常处理
 */
public class CustomRejectedExecutionHandler implements RejectedExecutionHandler {
    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        // 记录异常
        // 报警处理等
        System.out.println("执行自定义异常处理,当前线程池核心线程数为："+
                executor.getCorePoolSize()+",线程最大数为："+executor.getMaximumPoolSize()+","+"队列中等待数为:"+executor.getQueue().size());
    }
}
